{include file="public/head" /}
  
  <body>
    <div class="x-nav">
      <span class="layui-breadcrumb">
        <a><cite>后台管理</cite></a>
        <a><cite>物业管理系统</cite></a>
        <a><cite>小区单元列表</cite></a>
      </span>
      <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon" style="line-height:30px">ဂ</i></a>
    </div>
    <div class="x-body">
       <div class="layui-row">
        <form class="layui-form layui-col-md12 x-so"  method="get" action="#">
          <input class="layui-input" placeholder="小区名称" name="property_name" id="property_name" {if isset($community_name)}value="{$community_name}"{/if}>

            <div class="layui-input-inline">
                <select name="device_type" lay-filter="device_type" id="device_type">
                    <option value="">门禁类型</option>

                    <option value="1" {if isset($device_type)}{if $device_type ==1 }selected{/if}{/if}>大门</option>
                    <option value="2" {if isset($device_type)}{if $device_type == 2}selected{/if}{/if}>单元门</option>
                    <option value="3" {if isset($device_type)}{if $device_type == 3}selected{/if}{/if}>梯控</option>

                </select>
            </div>
            <button class="layui-btn"  lay-submit="" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button>
        </form>
      </div>
      <xblock>
        <button class="layui-btn" onclick="x_admin_show('添加','{:url('add')}',600,600)"><i class="layui-icon"></i>添加</button>
        <span class="x-right" style="line-height:40px">共有数据：{$number} 条</span>
      </xblock>
      <table class="layui-table" id="table">
        <thead  style="text-align:center;">
          <tr>
            <th style="text-align: center; font-size: 16px;">id</th>
            <th style="text-align: center; font-size: 16px;">小区名称</th>
            <th style="text-align: center; font-size: 16px;">单元</th>
            <th style="text-align: center; font-size: 16px;">门锁名</th>
            <th style="text-align: center; font-size: 16px;">设备序列号</th>
            <th style="text-align: center; font-size: 16px;">模组序列号</th>
            <th style="text-align: center; font-size: 16px;">二维码id</th>
            <th style="text-align: center; font-size: 16px;">状态</th>
            <th style="text-align: center; font-size: 16px;">类型</th>
            <th style="text-align: center; font-size: 16px;">开门类型</th>
            <th style="text-align: center; font-size: 16px;">操作</th>
          </tr>
        </thead>
        <tbody style="text-align:center;">
            {foreach $list as $lis}
            <tr>
              <td style="text-align: center;">{$lis.id}</td>
              <td style="text-align: center;">{$lis.community_name}</td>
              <td style="text-align: center;">
                  {if $lis.deviceType=='2'||$lis.deviceType=='3'}
                 {$lis.group}-{$lis.building}-{$lis.unit}
                  {/if}
              </td>
              <td style="text-align: center;">{$lis.lockname}</td>
              <td style="text-align: center;">{$lis.devicekey}</td>
              <td style="text-align: center;">{$lis.imei}</td>
              <td style="text-align: center;">
                 <span style="color:green">
                      {$lis.qrcode_id}
                 </span>
              </td>
                <td style="text-align: center;">
                    {if $lis.connect_status=='离线'}
                    <span style="color:red">
                        {$lis.connect_status}
                    </span>
                    {/if}
                    {if $lis.connect_status=='在线'}
                    <span >
                        {$lis.connect_status}
                    </span>
                    {/if}
                </td>
              <th style="text-align: center;">
                  {if $lis.deviceType == 1}
                  小区门
                  {/if}
                  {if $lis.deviceType == 2}
                  单元门
                  {/if}
                  {if $lis.deviceType ==3}
                  梯控
                  {/if}
              </th>
                <td style="text-align: center;">
                    {if $lis.lock_type == 1}
                    宇帆设备
                    {/if}
                    {if $lis.lock_type == 2}
                    模组
                    {/if}

                </td>
              <td class="td-manage" style="text-align: center;">
                  {if $lis.qrcode_id }
                  <a onclick="geturl('{$lis.qrcode_id}')" title="链接" href="javascript:;">
                      <i class="layui-icon">&#xe628; </i>
                  </a>
                  {/if}

                  <a title="修改"  onclick="x_admin_show('修改','{:url(\"edit\")}?id={$lis.id}',550,500)" href="javascript:;">
                    <i class="layui-icon">&#xe642;</i>
                  </a>
                  <a title="开门"  onclick="x_admin_show('开门','{:url(\"open\")}?id={$lis.id}',550,500)" href="javascript:;">
                    <i class="layui-icon">&#xe652;</i>
                  </a>
                  <a title="删除" onclick="del('{$lis.id}', '{$lis.id}')" href="javascript:;"  id="{$lis.id}" >
                    <i class="layui-icon">&#xe640;</i>
                  </a>
              </td>
            </tr>
            {/foreach}
        </tbody>
      </table>
      <div class="page">
        <div id="page">
            {$pagelist->render()|raw}
        </div>
      </div>

    </div>
    <script>
        function geturl(id){
            layer.open({
                type: 1,
                skin: 'x-right', //样式类名
                closeBtn: 0, //不显示关闭按钮
                anim: 2,
                shadeClose: true, //开启遮罩关闭
                area: ['80%', '300px'],
                content:
                    '<div style="padding: 20px 100px; font-size:18px">'+
                    '开门链接：alipays://platformapi/startapp?appId=2021006100621758&page=%2Fpages%2Fhome%2Fhome?id='+ id + '<br><br>'+


                    '</div>'
            });
        }
      layui.use('laydate', function(){
        var laydate = layui.laydate;
        
        //执行一个laydate实例
        laydate.render({
          elem: '#start' //指定元素
        });

        //执行一个laydate实例
        laydate.render({
          elem: '#end' //指定元素
        });
      });
      //删除
      function del(id, doc){
        if(confirm('确定要删除吗?')) 
        { 
          var url = "{:url('del')}?id=" + id
          // console.log(url)
          $('#' + doc).attr('href', url)
        } 
          return false; 
      } 

    </script>

    <script>var _hmt = _hmt || []; (function() {
        var hm = document.createElement("script");
        hm.src = "https://hm.baidu.com/hm.js?b393d153aeb26b46e9431fabaf0f6190";
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(hm, s);
      })();
    </script>

  </body>

</html>